<!DOCTYPE html>
<html class="x-admin-sm">
{block name="include"}{include file="head" /}{/block}
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form">
            <div class="layui-form-item">
                <label for="role_name" class="layui-form-label">
                    <span class="x-red">*</span>角色名字
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="role_name" name="role_name" required="" lay-verify="required"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label">
                </label>
                <button  class="layui-btn" lay-filter="add" lay-submit="">
                    增加
                </button>
            </div>
        </form>
    </div>
</div>
<script>layui.use(['form', 'layer'],
    function() {
        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer;

        //监听提交
        form.on('submit(add)', function(data) {
                $.ajax({
                    url: "{:url('admin/role/create')}",
                    type:'post',
                    data:data.field,
                    success:function (callback) {
                        if (callback.msg == 200){
                            layer.msg('增加成功',{icon:6});
                            setTimeout(function () {
                                xadmin.close();
                                // 可以对父窗口进行刷新
                                xadmin.father_reload();
                            },1200);
                        }else {
                            layer.msg("增加失败", {icon: 6})
                        }

                    }
                });
                return false;
            });

    });
</script>
</body>
</html>